package opera;

import book.BookList;

import java.util.Scanner;

public class BrrowOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        Scanner scanner=new Scanner(System.in);
        System.out.print("请输入借阅书名：");
        String name=scanner.nextLine();

        int currentSize=bookList.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            if(name.equals(bookList.getBooks(i).getName())) {
                if(bookList.getBooks(i).isBorrowed()==false) {
                    bookList.getBooks(i).setBorrowed(true);
                    System.out.println(bookList.getBooks(i));
                    System.out.println("您已成功借阅此书！");
                } else {
                    System.out.println("该书已被借出！");
                }
                return;
            }
        }
        System.out.println("未找到您需要的书籍！");
    }
}
